package com.yugao.fintech.framework.desensitization;

import com.yugao.fintech.framework.desensitization.fieldbind.*;
import com.yugao.fintech.framework.desensitization.fieldbind.aspect.FieldBindSetterAspect;
import com.yugao.fintech.framework.desensitization.fieldbind.inter.IDataBind;
import com.yugao.fintech.framework.desensitization.fieldsensitive.DefaultFieldSensitiveAnnotationGetter;
import com.yugao.fintech.framework.desensitization.fieldsensitive.FieldSensitiveHandler;
import com.yugao.fintech.framework.desensitization.fieldsensitive.aspect.FieldSensitiveHandleAspect;
import com.yugao.fintech.framework.desensitization.fieldbind.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

import javax.annotation.PostConstruct;

@AutoConfiguration
@Import({
    FieldBindHandler.class, FieldBindSetterAspect.class, DefaultFieldBindAnnotationGetter.class,
    FieldSensitiveHandler.class, DefaultFieldSensitiveAnnotationGetter.class, FieldSensitiveHandleAspect.class,

    FieldValueManager.class,
    SetTargetFieldValueHandler.StringSet.class, SetTargetFieldValueHandler.StringArray.class,
    SetTargetFieldValueHandler.StringList.class, SetTargetFieldValueHandler.StringType.class,
    GetSourceFieldValueHandler.StringType.class, GetSourceFieldValueHandler.IntegerArray.class,
    GetSourceFieldValueHandler.StringList.class, GetSourceFieldValueHandler.StringSet.class,
    GetSourceFieldValueHandler.IntegerType.class
})
public class LyDataMateAutoConfiguration {
    private static final Logger log = LoggerFactory.getLogger(LyDataMateAutoConfiguration.class);

    @PostConstruct
    public void init() {
        log.info("init {}", this.getClass().getName());
    }

    @Bean
    @ConditionalOnMissingBean(IDataBind.class)
    public DefaultDataBind defaultDataBind() {
        return new DefaultDataBind();
    }
}
